﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Common="clr-namespace:AzureDiagMon.Common">

    <Style TargetType="{x:Type Common:CheckableItemsWrapPanel}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Common:CheckableItemsWrapPanel}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <ScrollViewer x:Name="ScrollViewer1" 
                                          VerticalScrollBarVisibility="Auto" 
                                          HorizontalScrollBarVisibility="Auto">
                                <ItemsControl x:Name="ItemsControl1" ItemsSource="{TemplateBinding CheckableCollection}" >
                                    <ItemsControl.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <WrapPanel Orientation="Vertical" />
                                        </ItemsPanelTemplate>
                                    </ItemsControl.ItemsPanel>
                                    <!--<Setter Property="ItemTemplate">
                                        <Setter.Value>
                                            <Binding Source="{TemplateBinding ItemTemplate}" />
                                        </Setter.Value>
                                    </Setter>-->

                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <CheckBox IsChecked="{Binding Path=IsChecked, Mode=TwoWay}"
                                                      Content="{Binding Path=DisplayName}"
                                                      Margin="3" />
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>